package com.hsc.yalebao.db;

import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.misc.SqlExceptionUtil;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.DatabaseTable;
import com.j256.ormlite.table.DatabaseTableConfig;
import java.lang.reflect.Constructor;
import java.sql.SQLException;

public class UnlimitDaoManager
{
  public static <D extends Dao<T, ?>, T> D createDao(ConnectionSource paramConnectionSource, DatabaseTableConfig<T> paramDatabaseTableConfig)
    throws SQLException
  {
    if (paramConnectionSource == null)
      try
      {
        throw new IllegalArgumentException("connectionSource argument cannot be null");
      }
      finally
      {
      }
    Dao localDao = doCreateDao(paramConnectionSource, paramDatabaseTableConfig);
    return localDao;
  }

  private static <D extends Dao<T, ?>, T> D doCreateDao(ConnectionSource paramConnectionSource, DatabaseTableConfig<T> paramDatabaseTableConfig)
    throws SQLException
  {
    DatabaseTable localDatabaseTable = (DatabaseTable)paramDatabaseTableConfig.getDataClass().getAnnotation(DatabaseTable.class);
    if ((localDatabaseTable == null) || (localDatabaseTable.daoClass() == Void.class) || (localDatabaseTable.daoClass() == BaseDaoImpl.class))
      return null;
    Class localClass = localDatabaseTable.daoClass();
    Object[] arrayOfObject = { paramConnectionSource, paramDatabaseTableConfig };
    Constructor localConstructor = findConstructor(localClass, arrayOfObject);
    if (localConstructor == null)
      throw new SQLException("Could not find public constructor with ConnectionSource, DatabaseTableConfig parameters in class " + localClass);
    try
    {
      Dao localDao = (Dao)localConstructor.newInstance(arrayOfObject);
      return localDao;
    }
    catch (Exception localException)
    {
      throw SqlExceptionUtil.create("Could not call the constructor in class " + localClass, localException);
    }
  }

  private static Constructor<?> findConstructor(Class<?> paramClass, Object[] paramArrayOfObject)
  {
    Constructor[] arrayOfConstructor = paramClass.getConstructors();
    int i = arrayOfConstructor.length;
    int j = 0;
    if (j >= i)
    {
      localObject = null;
      label20: return localObject;
    }
    Object localObject = arrayOfConstructor[j];
    Class[] arrayOfClass = ((Constructor)localObject).getParameterTypes();
    int k;
    if (arrayOfClass.length == paramArrayOfObject.length)
      k = 1;
    label91: label93: for (int m = 0; ; m++)
    {
      if (m >= arrayOfClass.length);
      while (true)
      {
        if (k != 0)
          break label91;
        j++;
        break;
        if (arrayOfClass[m].isAssignableFrom(paramArrayOfObject[m].getClass()))
          break label93;
        k = 0;
      }
      break label20;
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.db.UnlimitDaoManager
 * JD-Core Version:    0.6.2
 */